<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\consts\Consts;
use common\business\EhrHelper;
use kartik\select2\Select2;
use yii\web\JsExpression;

/* @var $this yii\web\View */
/* @var $model common\models\qywx\QywxUserSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<style type="text/css">
    .label-search {
        width: 200px;
        /*text-align: right;*/
        padding-right: 3px;
    }

    .drop-search {
        min-width: 238px;
        /*width: 169.33px;*/
        /*max-width: 169.33px;*/
        width: 100%;
        text-align: center;
    }

    .input-date-min {
        width: 100px !important;
    }

    .select2{
        display: inline-block;
        text-align: center;
        /*min-width: 169.33px;*/
        /*width: auto !important;*/
        /*vertical-align: middle;*/
    }
</style>

<?php $form = ActiveForm::begin([
    'action' => 'index',
    'method' => 'get',
    "options" => ['class' => 'form-inline', 'id' => 'search_form'],
]); ?>

<div class="row">
    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
        <?= $form->field($model, 'name', ['template' => '{label} {input}', 'labelOptions' => ['class' => 'col-lg-4 col-md-4 col-sm-4 col-xs-4 control-label label-search']])
            ->textInput([
                'class' => 'form-control drop-search',
            ])
            ->label('姓名') ?>
    </div>
    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
        <?= $form->field($model, 'gender', ['template' => '{label} {input}', 'labelOptions' => ['class' => 'col-lg-4 col-md-4 col-sm-4 col-xs-4 control-label label-search']])
            ->dropDownList(EhrHelper::getGender_map(), [
                'class' => 'form-control drop-search',
                'prompt' => Consts::DEFAULT_PROMPT_PLS_SELECT,
            ])
            ->label('性别') ?>
    </div>
    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
        <?= $form->field($model, 'is_leader', ['template' => '{label} {input}', 'labelOptions' => ['class' => 'col-lg-4 col-md-4 col-sm-4 col-xs-4 control-label label-search']])
            ->dropDownList(EhrHelper::getQywxUserIsLeader_map(), [
                'class' => 'form-control drop-search',
                'prompt' => Consts::DEFAULT_PROMPT_PLS_SELECT,
            ])
            ->label('是否为领导') ?>
    </div>
    <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
        <?= $form->field($model, 'department', ['template' => '{label} {input}', 'labelOptions' => ['class' => 'col-lg-4 col-md-4 col-sm-4 col-xs-4 control-label label-search']])
            ->widget(Select2::className(), [
                'options' => [
                    'class' => 'form-control drop-search',
                    'placeholder' => Yii::t('app', Consts::DEFAULT_PROMPT_PLS_SELECT),
                ],
//            'theme' => Select2::THEME_KRAJEE,
                'pluginOptions' => [
                    'minimumInputLength' => 1,
                    'allowClear' => true,
                    'language' => [
                        'errorLoading' => new JsExpression("function () { return 'Waiting...'; }"),
                    ],
                    'ajax' => [
                        'url' => '/qywx/department/json-all',
                        'dataType' => 'json',
                        'data' => new JsExpression('function(params) { return {q:params.term}; }')
                    ],
                    'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                    'templateResult' => new JsExpression('function(res) { return res.text; }'),
                    'templateSelection' => new JsExpression('function (res) { return res.text; }'),
                ],
            ])
            ->label('部门') ?>
    </div>
</div>
<br>
<div class="form-group">
    <label class="control-label label-search"></label>
    <?= Html::submitButton('<span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询', [
        'class' => 'btn btn-primary btn-sm',
    ]) ?>
    <?= Html::button('<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 重置', [
        'class' => 'btn btn-primary btn-sm reset']) ?>
    <div class="help-block"></div>
</div>

<?php ActiveForm::end() ?>
